<?php


namespace app\middleware;

use app\BaseController;

use app\lib\exception\AuthException;
use app\lib\exception\ConfigurationException;
use app\lib\exception\ParamException;
use app\services\AuthService;
use think\App;
use think\Container;
use think\facade\Cache;
use think\Request;
use think\Response;

class BlackConfigurationWarehouseEndMiddleware extends BaseController
{

    /**
     * @var \think\cache\Driver
     */
    private $redis;
    private $leisureKey = 'cod_black_leisure_configuration_warehouse';
    private $busyKey = 'cod_black_busy_configuration_warehouse';

    public function __construct(App $app)
    {
        $this->redis =  Cache::store('redis');
        parent::__construct($app);
    }




    public function handle(Request $request, \Closure $next)
    {
        $response = $next($request);

        $bwc = $request->bcw;
        $this->redis->lRem($this->busyKey,$bwc['id'],1);
        $this->redis->lPush($this->leisureKey,$bwc['id']);
        // 添加中间件执行代码

        return $response;
    }


}